suppressPackageStartupMessages(library(tidyverse))
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'tidyr' was built under R version 4.2.3
## Warning: package 'readr' was built under R version 4.2.3
## Warning: package 'dplyr' was built under R version 4.2.3
## Warning: package 'stringr' was built under R version 4.2.3
devtools::load_all('~/Google Drive/My Drive/Scripts/R_packages/myUtilities/')
## ℹ Loading myUtilities
library(patchwork)
## Warning: package 'patchwork' was built under R version 4.2.3
wd <- "/Users/s-mitsutomi/My Drive (shuheimitsutomi@ric.u-tokyo.ac.jp)/Analysis/METTL2A/"
setwd(wd)

figdir <- paste0(wd, 'Figures/Espresso/Expression/')
tabledir <- paste0(wd, 'Tables/Espresso/Gprofiler/')

# # If parent has smaller pvalue, drop the term
# simplify_terms <- function(df) {
#   
#   term_ranks <-
#     df |>
#     arrange(p_value) |>
#     select(rank, query, term_id) |>
#     dplyr::rename(
#       parent_term_rank = rank, parent_term_id = term_id
#     )
#   
#   df |>
#     arrange(p_value) |>
#     select(rank, query, signed_log10p, source, term_name,
#            term_id, source_order, parents) |>
#     unnest_longer(col = parents) |>
#     dplyr::rename(parent_term_id = parents) |>
#     left_join(term_ranks) |>
#     group_by(rank) |> 
#     filter(is.na(parent_term_rank) | rank == min(parent_term_rank)) |>
#     ungroup() |> 
#     select(-starts_with('parent_')) |>
#     distinct()
#   
# } 

dual_barplot_theme <- function() {
  
  theme_classic(base_size = 7) +
    theme(
      axis.title.y = element_blank(),
      axis.text.y  = element_blank(),
      axis.line.y  = element_blank(),
      axis.ticks.y = element_blank()
    )
  
}

plot_dual_barplot_each_source <- function(.source, df) {
  
  barplot_basename <- paste0(
    df |> substitute() |> deparse(), '_', .source, '_dualbarplot'
  )
  
  df_source_simplified <- 
    df |> 
    filter(source == .source) |> 
    rownames_to_column(var = 'rank') 
  # |> 
  #   simplify_terms() 
  # 
  yrange_max <- df_source_simplified$signed_log10p |> abs() |> max(na.rm = TRUE)
  
  p1 <-
    df_source_simplified  |>
    select(query, signed_log10p, term_name, source) |>
    #filter(source == 'GO:BP') |>
    filter(query == 'down') |>
    head(10) |>
    ggplot(aes(x = reorder(term_name, -signed_log10p),
               y = signed_log10p, label = term_name)) +
    geom_bar(stat = 'identity', fill = 'blue', alpha = .2) +
    geom_text(hjust = 1, colour = 'black', y = -0.2, size = 7 * 0.36) +
    scale_y_continuous(limits = c(-yrange_max, 0)) +
    labs(title = .source) +
    coord_flip() +
    dual_barplot_theme()
  
  p2 <-
    df_source_simplified  |>
    select(query, signed_log10p, term_name, source) |>
    #filter(source == 'GO:BP') |>
    filter(query == 'up') |>
    head(10) |>
    ggplot(aes(x = reorder(term_name, signed_log10p),
               y = signed_log10p, label = term_name)) +
    geom_bar(stat = 'identity', fill = 'red', alpha = 0.2) +
    geom_text(hjust = 0, colour = 'black', y = 0.2, size = 7 * 0.36) +
    scale_y_continuous(limits = c(0, yrange_max)) +
    coord_flip() +
    dual_barplot_theme()
  
  dual_barplot <-  p1 | p2
  print(dual_barplot)
  
  ggsave(
    plot = dual_barplot, 
    filename = paste0(figdir, barplot_basename, '.pdf'),
    width = 12, height = 6, units = 'cm',
  )
  
}

gprofiler_gost <- function(ordered = TRUE) {
  
  gostres <-
    gprofiler2::gost(
      query = list(
        'up'   = str_remove(espresso_deseq2_commonup$transcript_id,
                            '[.][0-9]+$'),
        'down' = str_remove(espresso_deseq2_commondown$transcript_id,
                            '[.][0-9]+$')
      ),
      organism = 'hsapiens',
      ordered_query = ordered,
      significant = TRUE,
      #multi_query = TRUE
    )
  gostres$result |>
    as_tibble()
  
}

calc_signed_log10p <- function(df) {
  
  df |> 
    mutate(
      signed_log10p =
        ifelse(query == 'up', -log10(p_value), log10(p_value))
    ) |>
    arrange(p_value)
  
}

quickview_gprofiler_result <- function(df) {
  
  for (gp_source in unique(df$source)) {
    
    df |>
      filter(query == 'up') |> 
      filter(source == gp_source) |>
      select(query, p_value, term_name, source) |>
      head(20) |>
      print()
    
    df |>
      filter(query == 'down') |> 
      filter(source == gp_source) |>
      select(query, p_value, term_name, source) |>
      head(20) |>
      print()
    
    
  }
  
}

Read DESeq2 result

espresso_deseq2 <- 
  read_tsv(
    paste0(wd, 'Tables/Espresso/espresso_deseq2_genetype2_isDET_2024-04-01.tsv')
  )
## Rows: 36717 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (11): transcript_id, transcript_type, transcript_name, gene_id, gene_typ...
## dbl (18): siMETTL2A_baseMean, siMETTL2A_log2FoldChange, siMETTL2A_lfcSE, siM...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
espresso_deseq2
## # A tibble: 36,717 × 29
##    transcript_id     transcript_type transcript_name gene_id gene_type gene_name
##    <chr>             <chr>           <chr>           <chr>   <chr>     <chr>    
##  1 ENST00000498442.1 retained_intron CRBN-212        ENSG00… protein_… CRBN     
##  2 ENST00000459840.5 retained_intron CRBN-205        ENSG00… protein_… CRBN     
##  3 ENST00000231948.9 protein_coding  CRBN-201        ENSG00… protein_… CRBN     
##  4 ENST00000432408.6 protein_coding  CRBN-203        ENSG00… protein_… CRBN     
##  5 ENST00000339437.… protein_coding  TRNT1-203       ENSG00… protein_… TRNT1    
##  6 ENST00000488263.5 retained_intron CRBN-209        ENSG00… protein_… CRBN     
##  7 ENST00000420393.5 protein_coding  TRNT1-207       ENSG00… protein_… TRNT1    
##  8 ENST00000698415.1 retained_intron TRNT1-230       ENSG00… protein_… TRNT1    
##  9 ENST00000450014.1 protein_coding  CRBN-204        ENSG00… protein_… CRBN     
## 10 ENST00000698416.1 retained_intron TRNT1-231       ENSG00… protein_… TRNT1    
## # ℹ 36,707 more rows
## # ℹ 23 more variables: siMETTL2A_baseMean <dbl>,
## #   siMETTL2A_log2FoldChange <dbl>, siMETTL2A_lfcSE <dbl>,
## #   siMETTL2A_stat <dbl>, siMETTL2A_pvalue <dbl>, siMETTL2A_padj <dbl>,
## #   siMETTL2A_I_baseMean <dbl>, siMETTL2A_I_log2FoldChange <dbl>,
## #   siMETTL2A_I_lfcSE <dbl>, siMETTL2A_I_stat <dbl>, siMETTL2A_I_pvalue <dbl>,
## #   siMETTL2A_I_padj <dbl>, siMETTL2A_G_baseMean <dbl>, …
espresso_deseq2_commonDETs <- 
  espresso_deseq2 |> 
  filter(common_DETs != 'other')
espresso_deseq2_commonDETs
## # A tibble: 978 × 29
##    transcript_id     transcript_type transcript_name gene_id gene_type gene_name
##    <chr>             <chr>           <chr>           <chr>   <chr>     <chr>    
##  1 ENST00000301964.7 protein_coding  TADA3-201       ENSG00… protein_… TADA3    
##  2 ENST00000383817.5 protein_coding  CIDEC-202       ENSG00… protein_… CIDEC    
##  3 ENST00000344629.… protein_coding  OGG1-205        ENSG00… protein_… OGG1     
##  4 ENST00000306024.4 protein_coding  LSM3-201        ENSG00… protein_… LSM3     
##  5 ENST00000307839.… protein_coding  RPL15-201       ENSG00… protein_… RPL15    
##  6 ENST00000306627.8 protein_coding  UBE2E1-201      ENSG00… protein_… UBE2E1   
##  7 ENST00000479563.5 retained_intron RPL14-208       ENSG00… protein_… RPL14    
##  8 ENST00000338970.… protein_coding  RPL14-201       ENSG00… protein_… RPL14    
##  9 ENST00000438607.2 protein_coding  TMA7-201        ENSG00… protein_… TMA7     
## 10 ENST00000477624.1 retained_intron TMA7-202        ENSG00… protein_… TMA7     
## # ℹ 968 more rows
## # ℹ 23 more variables: siMETTL2A_baseMean <dbl>,
## #   siMETTL2A_log2FoldChange <dbl>, siMETTL2A_lfcSE <dbl>,
## #   siMETTL2A_stat <dbl>, siMETTL2A_pvalue <dbl>, siMETTL2A_padj <dbl>,
## #   siMETTL2A_I_baseMean <dbl>, siMETTL2A_I_log2FoldChange <dbl>,
## #   siMETTL2A_I_lfcSE <dbl>, siMETTL2A_I_stat <dbl>, siMETTL2A_I_pvalue <dbl>,
## #   siMETTL2A_I_padj <dbl>, siMETTL2A_G_baseMean <dbl>, …
espresso_deseq2_commonup <- 
  espresso_deseq2_commonDETs |> 
  filter(common_DETs == 'up')

espresso_deseq2_commondown <- 
  espresso_deseq2_commonDETs |> 
  filter(common_DETs == 'down')


# Enrichment analyses -----------------------------------------------------

gprofiler_result_ordered <- 
  gprofiler_gost(ordered = TRUE) |> 
  calc_signed_log10p()
gprofiler_result_ordered |> 
  export_tsv(outdir = tabledir, compression = 'gz')
## 
## Exported to: /Users/s-mitsutomi/My Drive (shuheimitsutomi@ric.u-tokyo.ac.jp)/Analysis/METTL2A/Tables/Espresso/Gprofiler/gprofiler_result_ordered_2024-04-17.tsv.gz
## # A tibble: 1,259 × 15
##    query significant  p_value term_size query_size intersection_size precision
##    <chr> <lgl>          <dbl>     <int>      <int>             <int>     <dbl>
##  1 down  TRUE        4.57e-26       635        475                71     0.149
##  2 down  TRUE        7.55e-25       402        475                54     0.114
##  3 up    TRUE        1.47e-24      2133        356               106     0.298
##  4 up    TRUE        1.53e-24      2134        356               106     0.298
##  5 up    TRUE        1.53e-24      2134        356               106     0.298
##  6 up    TRUE        2.42e-24      2109        356               105     0.295
##  7 down  TRUE        1.44e-23     12345        478               376     0.787
##  8 up    TRUE        3.34e-23      4004        357               149     0.417
##  9 down  TRUE        3.39e-23      4220        475               188     0.396
## 10 down  TRUE        7.43e-22      5487        478               220     0.460
## # ℹ 1,249 more rows
## # ℹ 8 more variables: recall <dbl>, term_id <chr>, source <chr>,
## #   term_name <chr>, effective_domain_size <int>, source_order <int>,
## #   parents <list>, signed_log10p <dbl>
gprofiler_result_notordered <- 
  gprofiler_gost(ordered = FALSE) |> 
  calc_signed_log10p()
gprofiler_result_notordered |> 
  export_tsv(outdir = tabledir, compression = 'gz')
## 
## Exported to: /Users/s-mitsutomi/My Drive (shuheimitsutomi@ric.u-tokyo.ac.jp)/Analysis/METTL2A/Tables/Espresso/Gprofiler/gprofiler_result_notordered_2024-04-17.tsv.gz
## # A tibble: 1,744 × 15
##    query significant  p_value term_size query_size intersection_size precision
##    <chr> <lgl>          <dbl>     <int>      <int>             <int>     <dbl>
##  1 down  TRUE        1.22e-27       635        449                71     0.158
##  2 down  TRUE        1.20e-26       547        333                75     0.225
##  3 down  TRUE        2.21e-26       677        333                83     0.249
##  4 down  TRUE        3.02e-26     12345        470               376     0.8  
##  5 up    TRUE        3.46e-26     12345        348               291     0.836
##  6 up    TRUE        4.21e-26      2133        348               107     0.307
##  7 up    TRUE        4.38e-26      2134        348               107     0.307
##  8 up    TRUE        4.38e-26      2134        348               107     0.307
##  9 up    TRUE        7.09e-26      2109        348               106     0.305
## 10 up    TRUE        3.88e-25      4004        348               150     0.431
## # ℹ 1,734 more rows
## # ℹ 8 more variables: recall <dbl>, term_id <chr>, source <chr>,
## #   term_name <chr>, effective_domain_size <int>, source_order <int>,
## #   parents <list>, signed_log10p <dbl>

Briefly check gprofiler results grouped by sources

quickview_gprofiler_result(gprofiler_result_ordered)
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 up    5.53e-18 cytoplasmic translation                                 GO:BP 
##  2 up    9.88e-18 aerobic electron transport chain                        GO:BP 
##  3 up    3.73e-17 mitochondrial ATP synthesis coupled electron transport  GO:BP 
##  4 up    3.73e-17 ATP synthesis coupled electron transport                GO:BP 
##  5 up    3.03e-16 oxidative phosphorylation                               GO:BP 
##  6 up    8.53e-16 respiratory electron transport chain                    GO:BP 
##  7 up    4.11e-14 aerobic respiration                                     GO:BP 
##  8 up    2.18e-13 electron transport chain                                GO:BP 
##  9 up    1.04e-12 cellular respiration                                    GO:BP 
## 10 up    6.26e-11 energy derivation by oxidation of organic compounds     GO:BP 
## 11 up    9.28e-10 generation of precursor metabolites and energy          GO:BP 
## 12 up    1.27e- 9 organonitrogen compound biosynthetic process            GO:BP 
## 13 up    1.29e- 9 peptide metabolic process                               GO:BP 
## 14 up    1.81e- 9 translation                                             GO:BP 
## 15 up    3.97e- 9 organonitrogen compound metabolic process               GO:BP 
## 16 up    6.51e- 9 peptide biosynthetic process                            GO:BP 
## 17 up    1.21e- 8 purine ribonucleoside triphosphate biosynthetic process GO:BP 
## 18 up    1.40e- 8 purine nucleoside triphosphate biosynthetic process     GO:BP 
## 19 up    1.59e- 8 amide metabolic process                                 GO:BP 
## 20 up    1.97e- 8 proton motive force-driven mitochondrial ATP synthesis  GO:BP 
## # A tibble: 20 × 4
##    query  p_value term_name                            source
##    <chr>    <dbl> <chr>                                <chr> 
##  1 down  4.57e-26 chromosome organization              GO:BP 
##  2 down  2.18e-21 cell cycle                           GO:BP 
##  3 down  1.99e-20 mitotic cell cycle                   GO:BP 
##  4 down  4.85e-20 chromosome segregation               GO:BP 
##  5 down  9.98e-19 mitotic sister chromatid segregation GO:BP 
##  6 down  1.11e-18 sister chromatid segregation         GO:BP 
##  7 down  2.23e-18 DNA metabolic process                GO:BP 
##  8 down  2.56e-18 mitotic cell cycle process           GO:BP 
##  9 down  7.59e-18 cell cycle process                   GO:BP 
## 10 down  4.75e-17 nuclear chromosome segregation       GO:BP 
## 11 down  5.49e-17 cell division                        GO:BP 
## 12 down  1.13e-15 mitotic nuclear division             GO:BP 
## 13 down  9.98e-15 DNA replication                      GO:BP 
## 14 down  4.96e-13 nuclear division                     GO:BP 
## 15 down  2.30e-12 chromosome separation                GO:BP 
## 16 down  2.74e-12 mitotic sister chromatid separation  GO:BP 
## 17 down  3.15e-12 regulation of chromosome segregation GO:BP 
## 18 down  3.78e-12 DNA-templated DNA replication        GO:BP 
## 19 down  4.36e-12 organelle fission                    GO:BP 
## 20 down  5.48e-12 regulation of chromosome separation  GO:BP 
## # A tibble: 20 × 4
##    query  p_value term_name                                    source
##    <chr>    <dbl> <chr>                                        <chr> 
##  1 up    1.47e-24 extracellular vesicle                        GO:CC 
##  2 up    1.53e-24 extracellular organelle                      GO:CC 
##  3 up    1.53e-24 extracellular membrane-bounded organelle     GO:CC 
##  4 up    2.42e-24 extracellular exosome                        GO:CC 
##  5 up    3.34e-23 vesicle                                      GO:CC 
##  6 up    5.75e-21 cytosolic ribosome                           GO:CC 
##  7 up    1.25e-19 cytoplasm                                    GO:CC 
##  8 up    1.39e-17 inner mitochondrial membrane protein complex GO:CC 
##  9 up    1.98e-17 ribosomal subunit                            GO:CC 
## 10 up    2.19e-17 respiratory chain complex                    GO:CC 
## 11 up    3.28e-17 mitochondrial respirasome                    GO:CC 
## 12 up    4.27e-17 extracellular space                          GO:CC 
## 13 up    5.54e-17 organelle membrane                           GO:CC 
## 14 up    8.99e-17 respirasome                                  GO:CC 
## 15 up    2.58e-16 mitochondrial protein-containing complex     GO:CC 
## 16 up    1.01e-14 cytoplasmic vesicle                          GO:CC 
## 17 up    1.15e-14 intracellular vesicle                        GO:CC 
## 18 up    3.58e-14 extracellular region                         GO:CC 
## 19 up    6.36e-14 secretory granule                            GO:CC 
## 20 up    8.65e-14 focal adhesion                               GO:CC 
## # A tibble: 20 × 4
##    query  p_value term_name                                source
##    <chr>    <dbl> <chr>                                    <chr> 
##  1 down  7.55e-25 chromosomal region                       GO:CC 
##  2 down  1.44e-23 cytoplasm                                GO:CC 
##  3 down  3.39e-23 nucleoplasm                              GO:CC 
##  4 down  7.43e-22 cytosol                                  GO:CC 
##  5 down  1.61e-20 organelle lumen                          GO:CC 
##  6 down  1.61e-20 intracellular organelle lumen            GO:CC 
##  7 down  1.61e-20 membrane-enclosed lumen                  GO:CC 
##  8 down  1.53e-16 chromosome, centromeric region           GO:CC 
##  9 down  2.55e-16 nuclear lumen                            GO:CC 
## 10 down  2.59e-15 condensed chromosome                     GO:CC 
## 11 down  4.63e-15 chromosome                               GO:CC 
## 12 down  5.58e-15 spindle                                  GO:CC 
## 13 down  9.61e-14 condensed chromosome, centromeric region GO:CC 
## 14 down  1.68e-13 kinetochore                              GO:CC 
## 15 down  2.13e-12 nuclear chromosome                       GO:CC 
## 16 down  3.03e-11 membrane-bounded organelle               GO:CC 
## 17 down  3.33e-11 intracellular membrane-bounded organelle GO:CC 
## 18 down  4.14e-11 intracellular anatomical structure       GO:CC 
## 19 down  2.60e-10 microtubule cytoskeleton                 GO:CC 
## 20 down  3.19e-10 catalytic complex                        GO:CC 
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 up    4.17e-17 oxidoreduction-driven active transmembrane transporter… GO:MF 
##  2 up    1.77e-15 electron transfer activity                              GO:MF 
##  3 up    1.64e-12 primary active transmembrane transporter activity       GO:MF 
##  4 up    2.09e- 9 cell adhesion molecule binding                          GO:MF 
##  5 up    1.92e- 8 NADH dehydrogenase (ubiquinone) activity                GO:MF 
##  6 up    2.23e- 8 NADH dehydrogenase (quinone) activity                   GO:MF 
##  7 up    2.32e- 8 cadherin binding                                        GO:MF 
##  8 up    3.00e- 8 NADH dehydrogenase activity                             GO:MF 
##  9 up    3.45e- 8 NAD(P)H dehydrogenase (quinone) activity                GO:MF 
## 10 up    9.28e- 8 active transmembrane transporter activity               GO:MF 
## 11 up    1.52e- 7 oxidoreductase activity, acting on NAD(P)H, quinone or… GO:MF 
## 12 up    6.98e- 7 structural constituent of ribosome                      GO:MF 
## 13 up    2.20e- 6 oxidoreductase activity, acting on NAD(P)H              GO:MF 
## 14 up    1.61e- 5 oxidoreductase activity                                 GO:MF 
## 15 up    3.91e- 5 transmembrane transporter activity                      GO:MF 
## 16 up    4.84e- 5 proton transmembrane transporter activity               GO:MF 
## 17 up    1.18e- 4 transporter activity                                    GO:MF 
## 18 up    1.54e- 4 cytochrome-c oxidase activity                           GO:MF 
## 19 up    1.54e- 4 oxidoreductase activity, acting on a heme group of don… GO:MF 
## 20 up    2.03e- 4 cadherin binding involved in cell-cell adhesion         GO:MF 
## # A tibble: 20 × 4
##    query  p_value term_name                             source
##    <chr>    <dbl> <chr>                                 <chr> 
##  1 down  1.10e-10 protein binding                       GO:MF 
##  2 down  4.21e- 9 single-stranded DNA helicase activity GO:MF 
##  3 down  2.01e- 7 catalytic activity                    GO:MF 
##  4 down  9.95e- 7 heterocyclic compound binding         GO:MF 
##  5 down  1.55e- 6 single-stranded DNA binding           GO:MF 
##  6 down  2.78e- 6 DNA helicase activity                 GO:MF 
##  7 down  2.88e- 6 cadherin binding                      GO:MF 
##  8 down  3.35e- 6 nucleotide binding                    GO:MF 
##  9 down  3.42e- 6 nucleoside phosphate binding          GO:MF 
## 10 down  4.29e- 5 purine nucleotide binding             GO:MF 
## 11 down  4.62e- 5 DNA polymerase binding                GO:MF 
## 12 down  5.87e- 5 anion binding                         GO:MF 
## 13 down  7.39e- 5 adenyl nucleotide binding             GO:MF 
## 14 down  9.18e- 5 identical protein binding             GO:MF 
## 15 down  1.36e- 4 chromatin binding                     GO:MF 
## 16 down  2.23e- 4 cell adhesion molecule binding        GO:MF 
## 17 down  2.83e- 4 ribonucleotide binding                GO:MF 
## 18 down  3.77e- 4 enzyme binding                        GO:MF 
## 19 down  5.73e- 4 carbohydrate derivative binding       GO:MF 
## 20 down  8.18e- 4 purine ribonucleotide binding         GO:MF 
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 up    7.27e-16 Eukaryotic Translation Elongation                       REAC  
##  2 up    3.02e-15 Peptide chain elongation                                REAC  
##  3 up    9.66e-15 SRP-dependent cotranslational protein targeting to mem… REAC  
##  4 up    3.98e-14 Viral mRNA Translation                                  REAC  
##  5 up    8.01e-14 Formation of a pool of free 40S subunits                REAC  
##  6 up    8.01e-14 Response of EIF2AK4 (GCN2) to amino acid deficiency     REAC  
##  7 up    1.19e-13 Eukaryotic Translation Termination                      REAC  
##  8 up    1.19e-13 Selenocysteine synthesis                                REAC  
##  9 up    2.00e-13 Nonsense Mediated Decay (NMD) independent of the Exon … REAC  
## 10 up    6.52e-13 Cellular response to starvation                         REAC  
## 11 up    8.63e-13 L13a-mediated translational silencing of Ceruloplasmin… REAC  
## 12 up    1.08e-12 GTP hydrolysis and joining of the 60S ribosomal subunit REAC  
## 13 up    4.80e-12 Cap-dependent Translation Initiation                    REAC  
## 14 up    4.80e-12 Eukaryotic Translation Initiation                       REAC  
## 15 up    7.06e-12 Respiratory electron transport, ATP synthesis by chemi… REAC  
## 16 up    1.96e-11 Nonsense Mediated Decay (NMD) enhanced by the Exon Jun… REAC  
## 17 up    1.96e-11 Nonsense-Mediated Decay (NMD)                           REAC  
## 18 up    2.40e-11 Selenoamino acid metabolism                             REAC  
## 19 up    2.57e-11 Respiratory electron transport                          REAC  
## 20 up    5.84e-11 Influenza Viral RNA Transcription and Replication       REAC  
## # A tibble: 20 × 4
##    query  p_value term_name                                  source
##    <chr>    <dbl> <chr>                                      <chr> 
##  1 down  9.11e-17 Cell Cycle, Mitotic                        REAC  
##  2 down  3.44e-16 Cell Cycle                                 REAC  
##  3 down  2.02e- 9 DNA strand elongation                      REAC  
##  4 down  7.49e- 9 Resolution of Sister Chromatid Cohesion    REAC  
##  5 down  9.17e- 9 Mitotic Metaphase and Anaphase             REAC  
##  6 down  3.09e- 8 Mitotic G1 phase and G1/S transition       REAC  
##  7 down  3.51e- 8 Mitotic Anaphase                           REAC  
##  8 down  6.79e- 8 G1/S Transition                            REAC  
##  9 down  7.72e- 8 Mitotic Prometaphase                       REAC  
## 10 down  2.08e- 7 Synthesis of DNA                           REAC  
## 11 down  4.94e- 7 S Phase                                    REAC  
## 12 down  5.38e- 7 Cell Cycle Checkpoints                     REAC  
## 13 down  1.41e- 6 Separation of Sister Chromatids            REAC  
## 14 down  2.08e- 6 EML4 and NUDC in mitotic spindle formation REAC  
## 15 down  4.77e- 6 Lagging Strand Synthesis                   REAC  
## 16 down  6.22e- 6 Leading Strand Synthesis                   REAC  
## 17 down  6.22e- 6 Polymerase switching                       REAC  
## 18 down  1.09e- 5 RHO GTPases Activate Formins               REAC  
## 19 down  1.10e- 5 Activation of the pre-replicative complex  REAC  
## 20 down  1.27e- 5 M Phase                                    REAC  
## # A tibble: 11 × 4
##    query    p_value term_name      source
##    <chr>      <dbl> <chr>          <chr> 
##  1 up    0.00000180 hsa-let-7c-5p  MIRNA 
##  2 up    0.000342   hsa-let-7e-5p  MIRNA 
##  3 up    0.00242    hsa-miR-296-3p MIRNA 
##  4 up    0.00827    hsa-miR-17-5p  MIRNA 
##  5 up    0.00984    hsa-miR-4460   MIRNA 
##  6 up    0.0138     hsa-miR-652-3p MIRNA 
##  7 up    0.0188     hsa-miR-140-5p MIRNA 
##  8 up    0.0286     hsa-miR-744-5p MIRNA 
##  9 up    0.0372     hsa-miR-30a-5p MIRNA 
## 10 up    0.0396     hsa-let-7a-5p  MIRNA 
## 11 up    0.0444     hsa-miR-186-5p MIRNA 
## # A tibble: 9 × 4
##   query  p_value term_name       source
##   <chr>    <dbl> <chr>           <chr> 
## 1 down  2.27e-16 hsa-miR-193b-3p MIRNA 
## 2 down  4.82e- 4 hsa-miR-744-5p  MIRNA 
## 3 down  1.09e- 3 hsa-miR-615-3p  MIRNA 
## 4 down  5.00e- 3 hsa-miR-484     MIRNA 
## 5 down  1.07e- 2 hsa-miR-34a-5p  MIRNA 
## 6 down  2.36e- 2 hsa-miR-4758-3p MIRNA 
## 7 down  2.95e- 2 hsa-miR-4721    MIRNA 
## 8 down  3.21e- 2 hsa-miR-4669    MIRNA 
## 9 down  4.17e- 2 hsa-miR-497-3p  MIRNA 
## # A tibble: 20 × 4
##    query  p_value term_name                                     source
##    <chr>    <dbl> <chr>                                         <chr> 
##  1 up    5.08e-16 Mitochondrial inheritance                     HP    
##  2 up    9.43e-15 Centrocecal scotoma                           HP    
##  3 up    1.19e-13 Leber optic atrophy                           HP    
##  4 up    1.20e-12 Ventricular preexcitation                     HP    
##  5 up    1.29e-12 Retinal arterial tortuosity                   HP    
##  6 up    1.29e-12 Central retinal vessel vascular tortuosity    HP    
##  7 up    2.15e-12 Mitochondrial respiratory chain defects       HP    
##  8 up    5.82e-11 Retinal telangiectasia                        HP    
##  9 up    6.31e-10 Slow decrease in visual acuity                HP    
## 10 up    8.62e-10 Episodic vomiting                             HP    
## 11 up    1.29e- 9 Mitochondrial myopathy                        HP    
## 12 up    1.29e- 9 Ragged-red muscle fibers                      HP    
## 13 up    2.49e- 9 Abnormal mitochondria in muscle tissue        HP    
## 14 up    5.42e- 9 Arterial tortuosity                           HP    
## 15 up    8.16e- 9 Blurred vision                                HP    
## 16 up    1.57e- 8 Mixed demyelinating and axonal polyneuropathy HP    
## 17 up    1.89e- 8 Vascular tortuosity                           HP    
## 18 up    1.91e- 8 Multiple glomerular cysts                     HP    
## 19 up    3.40e- 8 Central scotoma                               HP    
## 20 up    4.36e- 8 Stroke-like episode                           HP    
## # A tibble: 0 × 4
## # ℹ 4 variables: query <chr>, p_value <dbl>, term_name <chr>, source <chr>
## # A tibble: 7 × 4
##   query  p_value term_name                                              source
##   <chr>    <dbl> <chr>                                                  <chr> 
## 1 up    1.63e-13 Electron transport chain OXPHOS system in mitochondria WP    
## 2 up    3.83e-11 Cytoplasmic ribosomal proteins                         WP    
## 3 up    5.42e- 7 Oxidative phosphorylation                              WP    
## 4 up    3.52e- 4 Mitochondrial complex I assembly model OXPHOS system   WP    
## 5 up    1.13e- 2 Mitochondrial complex III assembly                     WP    
## 6 up    1.66e- 2 Nonalcoholic fatty liver disease                       WP    
## 7 up    3.41e- 2 Mitochondrial complex IV assembly                      WP    
## # A tibble: 8 × 4
##   query  p_value term_name                                  source
##   <chr>    <dbl> <chr>                                      <chr> 
## 1 down  4.95e-11 Retinoblastoma gene in cancer              WP    
## 2 down  1.31e- 8 DNA replication                            WP    
## 3 down  1.59e- 3 Gastric cancer network 1                   WP    
## 4 down  2.42e- 3 G1 to S cell cycle control                 WP    
## 5 down  6.25e- 3 DNA mismatch repair                        WP    
## 6 down  3.10e- 2 Gastric cancer network 2                   WP    
## 7 down  3.27e- 2 Cell cycle                                 WP    
## 8 down  4.69e- 2 Cohesin complex Cornelia de Lange syndrome WP    
## # A tibble: 16 × 4
##    query  p_value term_name                                         source
##    <chr>    <dbl> <chr>                                             <chr> 
##  1 up    1.81e-12 Oxidative phosphorylation                         KEGG  
##  2 up    3.77e-10 Diabetic cardiomyopathy                           KEGG  
##  3 up    1.19e- 9 Chemical carcinogenesis - reactive oxygen species KEGG  
##  4 up    2.08e- 9 Ribosome                                          KEGG  
##  5 up    2.20e- 9 Thermogenesis                                     KEGG  
##  6 up    3.62e- 9 Parkinson disease                                 KEGG  
##  7 up    4.59e- 9 Huntington disease                                KEGG  
##  8 up    1.55e- 8 Prion disease                                     KEGG  
##  9 up    5.63e- 7 Amyotrophic lateral sclerosis                     KEGG  
## 10 up    9.70e- 7 Pathways of neurodegeneration - multiple diseases KEGG  
## 11 up    1.00e- 6 Alzheimer disease                                 KEGG  
## 12 up    7.68e- 5 Coronavirus disease - COVID-19                    KEGG  
## 13 up    1.18e- 4 Cardiac muscle contraction                        KEGG  
## 14 up    1.34e- 3 Retrograde endocannabinoid signaling              KEGG  
## 15 up    7.68e- 3 Non-alcoholic fatty liver disease                 KEGG  
## 16 up    4.98e- 2 Ubiquitin mediated proteolysis                    KEGG  
## # A tibble: 4 × 4
##   query       p_value term_name            source
##   <chr>         <dbl> <chr>                <chr> 
## 1 down  0.00000000196 DNA replication      KEGG  
## 2 down  0.000133      Cell cycle           KEGG  
## 3 down  0.00532       Mismatch repair      KEGG  
## 4 down  0.00643       Base excision repair KEGG  
## # A tibble: 20 × 4
##    query   p_value term_name                                            source
##    <chr>     <dbl> <chr>                                                <chr> 
##  1 up    0.0000360 Factor: ER71; motif: ACCGGAARYN; match class: 1      TF    
##  2 up    0.000220  Factor: MYBL1; motif: ACCGTTAACSGY                   TF    
##  3 up    0.000290  Factor: SAP-1; motif: NRNCGGAWRYN                    TF    
##  4 up    0.000354  Factor: Kaiso; motif: TCTCGCGAG; match class: 1      TF    
##  5 up    0.000494  Factor: Cdx-2; motif: NRTCGTAANNNN; match class: 1   TF    
##  6 up    0.000510  Factor: Fli-1; motif: ACCGGAAGYN                     TF    
##  7 up    0.000518  Factor: GABPalpha; motif: RCCGGAWRYN; match class: 1 TF    
##  8 up    0.000553  Factor: E2F; motif: GGCGSG                           TF    
##  9 up    0.000566  Factor: E2F1; motif: NNNNNGCGSSAAAN                  TF    
## 10 up    0.000780  Factor: FLI1; motif: ACCGGAARTN; match class: 1      TF    
## 11 up    0.00100   Factor: LRF; motif: NCGACCACCGN; match class: 1      TF    
## 12 up    0.00120   Factor: Erg; motif: NACCGGAARYN; match class: 1      TF    
## 13 up    0.00123   Factor: E2F-4:DP-1; motif: TTTSGCGC                  TF    
## 14 up    0.00133   Factor: Erg; motif: ACCGGAAGTN; match class: 1       TF    
## 15 up    0.00181   Factor: E2F; motif: GGCGSG; match class: 1           TF    
## 16 up    0.00184   Factor: FLI-1; motif: NAYTTCCGGT; match class: 1     TF    
## 17 up    0.00261   Factor: Kaiso; motif: TCTCGCGAG                      TF    
## 18 up    0.00308   Factor: c-ets-2; motif: ACCGGAWRTN                   TF    
## 19 up    0.00340   Factor: Fli-1; motif: NACCGGAARTN; match class: 1    TF    
## 20 up    0.00344   Factor: GCMb:FOXI1; motif: RTAAATANGGGNN             TF    
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 down  3.12e-12 Factor: E2F-4; motif: NTTTCSCGCC; match class: 1        TF    
##  2 down  1.21e-11 Factor: E2F-1; motif: NNNSSCGCSAANN                     TF    
##  3 down  3.60e-11 Factor: E2F-4; motif: SNGGGCGGGAANN; match class: 1     TF    
##  4 down  6.56e-11 Factor: E2F; motif: TTTSGCGSG                           TF    
##  5 down  7.03e-11 Factor: E2F; motif: NKCGCGCSAAAN                        TF    
##  6 down  1.23e-10 Factor: E2F-1; motif: NGGGCGGGARV; match class: 1       TF    
##  7 down  1.38e-10 Factor: E2F; motif: NCSCGCSAAAN                         TF    
##  8 down  2.21e-10 Factor: ZF5; motif: NRNGNGCGCGCWN; match class: 1       TF    
##  9 down  1.40e- 9 Factor: ER81; motif: RCCGGAARYN; match class: 1         TF    
## 10 down  2.97e- 9 Factor: ZF5; motif: GGSGCGCGS; match class: 1           TF    
## 11 down  3.20e- 9 Factor: E2F-1; motif: TTTSGCGCGMNR                      TF    
## 12 down  1.43e- 8 Factor: E2F; motif: TTTSGCGSG                           TF    
## 13 down  1.72e- 8 Factor: ZF5; motif: NRNGNGCGCGCWN                       TF    
## 14 down  3.65e- 8 Factor: E2F-1; motif: NNNSSCGCSAANN; match class: 1     TF    
## 15 down  5.84e- 8 Factor: E2F4; motif: YCCCGCCNCNNSSNNSNN; match class: 1 TF    
## 16 down  8.57e- 8 Factor: E2F-1; motif: TTTSGCGS                          TF    
## 17 down  1.26e- 7 Factor: E2F1; motif: GSGCGGGAAN                         TF    
## 18 down  1.71e- 7 Factor: E2F-4; motif: NTTTCSCGCC                        TF    
## 19 down  1.76e- 7 Factor: ZF5; motif: GSGCGCGR; match class: 1            TF    
## 20 down  1.98e- 7 Factor: ZF5; motif: GGSGCGCGS                           TF    
## # A tibble: 20 × 4
##    query  p_value term_name                               source
##    <chr>    <dbl> <chr>                                   <chr> 
##  1 up    0.000194 skin 2; fibrohistiocytic cells[≥Medium] HPA   
##  2 up    0.000245 skin 1; fibrohistiocytic cells[≥Low]    HPA   
##  3 up    0.000991 skin 2; fibrohistiocytic cells[≥Low]    HPA   
##  4 up    0.00253  skin 1; fibrohistiocytic cells[≥Medium] HPA   
##  5 up    0.00286  skin 1; endothelial cells[≥Low]         HPA   
##  6 up    0.00312  skin 1; cells in basal layer[≥Low]      HPA   
##  7 up    0.00390  skin 2; endothelial cells[≥Low]         HPA   
##  8 up    0.00402  skin 1; lymphocytes[≥Low]               HPA   
##  9 up    0.00447  skin 2; cells in basal layer[≥Low]      HPA   
## 10 up    0.00745  skin 2; endothelial cells[≥Medium]      HPA   
## 11 up    0.00762  skin 2; cells in basal layer[≥Medium]   HPA   
## 12 up    0.0101   skin 1; langerhans cells[≥Low]          HPA   
## 13 up    0.0110   skin 2; langerhans cells[≥Low]          HPA   
## 14 up    0.0164   skin 2; lymphocytes[≥Low]               HPA   
## 15 up    0.0165   skin 1; endothelial cells[≥Medium]      HPA   
## 16 up    0.0172   skin 2; lymphocytes[≥Medium]            HPA   
## 17 up    0.0303   skin 1; lymphocytes[High]               HPA   
## 18 up    0.0360   skin 2; langerhans cells[≥Medium]       HPA   
## 19 up    0.0401   skin 1; lymphocytes[≥Medium]            HPA   
## 20 up    0.0421   skin 1; cells in basal layer[≥Medium]   HPA   
## # A tibble: 20 × 4
##    query       p_value term_name                               source
##    <chr>         <dbl> <chr>                                   <chr> 
##  1 down  0.00000000661 skin 2; cells in spinous layer[≥Low]    HPA   
##  2 down  0.0000000296  skin 1; cells in basal layer[≥Low]      HPA   
##  3 down  0.0000000451  skin 1; cells in spinous layer[≥Low]    HPA   
##  4 down  0.000000160   skin 2; cells in basal layer[≥Low]      HPA   
##  5 down  0.000000235   skin 2; cells in spinous layer[≥Medium] HPA   
##  6 down  0.00000263    skin 1; cells in spinous layer[≥Medium] HPA   
##  7 down  0.00000295    skin 1; cells in basal layer[≥Medium]   HPA   
##  8 down  0.00000305    skin 2; cells in basal layer[≥Medium]   HPA   
##  9 down  0.0000240     skin 2; cells in basal layer[High]      HPA   
## 10 down  0.000338      skin 1; langerhans cells[≥Low]          HPA   
## 11 down  0.00113       skin 1; lymphocytes[≥Medium]            HPA   
## 12 down  0.00129       skin 1; fibrohistiocytic cells[High]    HPA   
## 13 down  0.00137       skin 1; langerhans cells[≥Medium]       HPA   
## 14 down  0.00147       skin 2; lymphocytes[≥Low]               HPA   
## 15 down  0.00149       skin 2; lymphocytes[≥Medium]            HPA   
## 16 down  0.00151       skin 1; cells in basal layer[High]      HPA   
## 17 down  0.00184       bone marrow; hematopoietic cells[High]  HPA   
## 18 down  0.00226       skin 1; lymphocytes[High]               HPA   
## 19 down  0.00228       skin 1; hair follicles[≥Low]            HPA   
## 20 down  0.00245       skin 1; endothelial cells[High]         HPA   
## # A tibble: 6 × 4
##   query  p_value term_name                                                source
##   <chr>    <dbl> <chr>                                                    <chr> 
## 1 up    0.000845 Respiratory chain complex I (incomplete intermediate ND… CORUM 
## 2 up    0.000955 Ribosome, cytoplasmic                                    CORUM 
## 3 up    0.00119  Respiratory chain complex I (gamma subunit) mitochondri… CORUM 
## 4 up    0.0119   Respiratory chain complex I (holoenzyme), mitochondrial  CORUM 
## 5 up    0.0487   Cytochrome c oxidase, mitochondrial                      CORUM 
## 6 up    0.0491   40S ribosomal subunit, cytoplasmic                       CORUM 
## # A tibble: 1 × 4
##   query p_value term_name                                  source
##   <chr>   <dbl> <chr>                                      <chr> 
## 1 down   0.0333 RC complex (Replication competent complex) CORUM
quickview_gprofiler_result(gprofiler_result_notordered)
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 up    2.09e-18 cytoplasmic translation                                 GO:BP 
##  2 up    9.40e-16 oxidative phosphorylation                               GO:BP 
##  3 up    1.52e-15 aerobic electron transport chain                        GO:BP 
##  4 up    9.66e-15 mitochondrial ATP synthesis coupled electron transport  GO:BP 
##  5 up    9.66e-15 ATP synthesis coupled electron transport                GO:BP 
##  6 up    3.16e-13 organonitrogen compound metabolic process               GO:BP 
##  7 up    7.11e-13 respiratory electron transport chain                    GO:BP 
##  8 up    1.56e-12 aerobic respiration                                     GO:BP 
##  9 up    5.25e-12 organonitrogen compound biosynthetic process            GO:BP 
## 10 up    1.21e-11 electron transport chain                                GO:BP 
## 11 up    8.20e-11 peptide metabolic process                               GO:BP 
## 12 up    1.21e-10 translation                                             GO:BP 
## 13 up    2.63e-10 cellular respiration                                    GO:BP 
## 14 up    4.61e-10 peptide biosynthetic process                            GO:BP 
## 15 up    1.09e- 9 amide metabolic process                                 GO:BP 
## 16 up    1.98e- 9 amide biosynthetic process                              GO:BP 
## 17 up    4.93e- 9 purine ribonucleoside triphosphate biosynthetic process GO:BP 
## 18 up    5.71e- 9 purine nucleoside triphosphate biosynthetic process     GO:BP 
## 19 up    1.17e- 8 ribonucleoside triphosphate biosynthetic process        GO:BP 
## 20 up    1.55e- 8 protein metabolic process                               GO:BP 
## # A tibble: 20 × 4
##    query  p_value term_name                            source
##    <chr>    <dbl> <chr>                                <chr> 
##  1 down  1.22e-27 chromosome organization              GO:BP 
##  2 down  8.08e-24 cell cycle                           GO:BP 
##  3 down  5.28e-22 mitotic cell cycle                   GO:BP 
##  4 down  2.86e-21 chromosome segregation               GO:BP 
##  5 down  6.65e-20 DNA metabolic process                GO:BP 
##  6 down  1.07e-19 cell cycle process                   GO:BP 
##  7 down  1.10e-19 mitotic cell cycle process           GO:BP 
##  8 down  1.51e-19 sister chromatid segregation         GO:BP 
##  9 down  1.56e-19 mitotic sister chromatid segregation GO:BP 
## 10 down  2.53e-18 cell division                        GO:BP 
## 11 down  5.62e-18 nuclear chromosome segregation       GO:BP 
## 12 down  1.63e-16 mitotic nuclear division             GO:BP 
## 13 down  1.21e-14 DNA replication                      GO:BP 
## 14 down  6.08e-14 nuclear division                     GO:BP 
## 15 down  3.56e-13 organelle organization               GO:BP 
## 16 down  5.33e-13 organelle fission                    GO:BP 
## 17 down  7.83e-13 chromosome separation                GO:BP 
## 18 down  8.94e-13 regulation of chromosome segregation GO:BP 
## 19 down  1.03e-12 mitotic sister chromatid separation  GO:BP 
## 20 down  1.96e-12 regulation of chromosome separation  GO:BP 
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 up    8.49e-19 Eukaryotic Translation Elongation                       REAC  
##  2 up    4.62e-18 Peptide chain elongation                                REAC  
##  3 up    9.55e-18 SRP-dependent cotranslational protein targeting to mem… REAC  
##  4 up    6.41e-17 Cellular response to starvation                         REAC  
##  5 up    8.17e-17 Viral mRNA Translation                                  REAC  
##  6 up    1.33e-16 Response of EIF2AK4 (GCN2) to amino acid deficiency     REAC  
##  7 up    1.33e-16 Formation of a pool of free 40S subunits                REAC  
##  8 up    2.51e-16 Eukaryotic Translation Termination                      REAC  
##  9 up    2.51e-16 Selenocysteine synthesis                                REAC  
## 10 up    4.29e-16 Nonsense Mediated Decay (NMD) independent of the Exon … REAC  
## 11 up    1.54e-15 L13a-mediated translational silencing of Ceruloplasmin… REAC  
## 12 up    1.93e-15 GTP hydrolysis and joining of the 60S ribosomal subunit REAC  
## 13 up    9.03e-15 Eukaryotic Translation Initiation                       REAC  
## 14 up    9.03e-15 Cap-dependent Translation Initiation                    REAC  
## 15 up    4.81e-14 Nonsense-Mediated Decay (NMD)                           REAC  
## 16 up    4.81e-14 Nonsense Mediated Decay (NMD) enhanced by the Exon Jun… REAC  
## 17 up    5.93e-14 Selenoamino acid metabolism                             REAC  
## 18 up    1.20e-13 Influenza Viral RNA Transcription and Replication       REAC  
## 19 up    3.31e-13 Influenza Infection                                     REAC  
## 20 up    6.27e-12 Regulation of expression of SLITs and ROBOs             REAC  
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 down  1.20e-26 Cell Cycle, Mitotic                                     REAC  
##  2 down  2.21e-26 Cell Cycle                                              REAC  
##  3 down  1.82e-13 Mitotic Metaphase and Anaphase                          REAC  
##  4 down  1.02e-12 Mitotic Anaphase                                        REAC  
##  5 down  1.91e-12 Resolution of Sister Chromatid Cohesion                 REAC  
##  6 down  4.54e-12 Mitotic Prometaphase                                    REAC  
##  7 down  1.06e-11 Cell Cycle Checkpoints                                  REAC  
##  8 down  2.18e-11 Mitotic G1 phase and G1/S transition                    REAC  
##  9 down  6.59e-11 G1/S Transition                                         REAC  
## 10 down  9.34e-11 M Phase                                                 REAC  
## 11 down  2.60e-10 Separation of Sister Chromatids                         REAC  
## 12 down  1.80e- 9 DNA strand elongation                                   REAC  
## 13 down  2.26e- 9 EML4 and NUDC in mitotic spindle formation              REAC  
## 14 down  6.57e- 9 Synthesis of DNA                                        REAC  
## 15 down  1.05e- 8 RHO GTPases Activate Formins                            REAC  
## 16 down  1.11e- 8 S Phase                                                 REAC  
## 17 down  4.84e- 8 Mitotic Spindle Checkpoint                              REAC  
## 18 down  1.42e- 7 Amplification  of signal from unattached  kinetochores… REAC  
## 19 down  1.42e- 7 Amplification of signal from the kinetochores           REAC  
## 20 down  7.97e- 7 Mitotic G2-G2/M phases                                  REAC  
## # A tibble: 20 × 4
##    query  p_value term_name                                    source
##    <chr>    <dbl> <chr>                                        <chr> 
##  1 up    3.46e-26 cytoplasm                                    GO:CC 
##  2 up    4.21e-26 extracellular vesicle                        GO:CC 
##  3 up    4.38e-26 extracellular membrane-bounded organelle     GO:CC 
##  4 up    4.38e-26 extracellular organelle                      GO:CC 
##  5 up    7.09e-26 extracellular exosome                        GO:CC 
##  6 up    3.88e-25 vesicle                                      GO:CC 
##  7 up    3.07e-20 cytosolic ribosome                           GO:CC 
##  8 up    1.63e-18 extracellular space                          GO:CC 
##  9 up    1.39e-17 inner mitochondrial membrane protein complex GO:CC 
## 10 up    5.45e-17 organelle membrane                           GO:CC 
## 11 up    1.06e-16 mitochondrial protein-containing complex     GO:CC 
## 12 up    1.13e-16 ribosomal subunit                            GO:CC 
## 13 up    1.97e-16 respirasome                                  GO:CC 
## 14 up    5.66e-16 extracellular region                         GO:CC 
## 15 up    5.95e-16 mitochondrial respirasome                    GO:CC 
## 16 up    1.53e-15 cytoplasmic vesicle                          GO:CC 
## 17 up    1.75e-15 intracellular vesicle                        GO:CC 
## 18 up    5.60e-15 respiratory chain complex                    GO:CC 
## 19 up    5.60e-15 endomembrane system                          GO:CC 
## 20 up    2.35e-14 secretory granule                            GO:CC 
## # A tibble: 20 × 4
##    query  p_value term_name                                source
##    <chr>    <dbl> <chr>                                    <chr> 
##  1 down  3.02e-26 cytoplasm                                GO:CC 
##  2 down  4.46e-25 chromosomal region                       GO:CC 
##  3 down  7.48e-24 nucleoplasm                              GO:CC 
##  4 down  4.66e-23 cytosol                                  GO:CC 
##  5 down  9.20e-22 intracellular organelle lumen            GO:CC 
##  6 down  9.20e-22 membrane-enclosed lumen                  GO:CC 
##  7 down  9.20e-22 organelle lumen                          GO:CC 
##  8 down  2.44e-17 nuclear lumen                            GO:CC 
##  9 down  1.08e-16 chromosome, centromeric region           GO:CC 
## 10 down  1.84e-15 condensed chromosome                     GO:CC 
## 11 down  2.13e-15 chromosome                               GO:CC 
## 12 down  3.20e-15 spindle                                  GO:CC 
## 13 down  5.98e-14 intracellular anatomical structure       GO:CC 
## 14 down  7.33e-14 condensed chromosome, centromeric region GO:CC 
## 15 down  1.29e-13 kinetochore                              GO:CC 
## 16 down  3.06e-13 membrane-bounded organelle               GO:CC 
## 17 down  1.81e-12 nuclear chromosome                       GO:CC 
## 18 down  3.08e-12 intracellular membrane-bounded organelle GO:CC 
## 19 down  4.58e-12 intracellular organelle                  GO:CC 
## 20 down  1.11e-11 organelle                                GO:CC 
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 up    8.18e-11 protein binding                                         GO:MF 
##  2 up    3.56e-10 electron transfer activity                              GO:MF 
##  3 up    5.11e-10 cell adhesion molecule binding                          GO:MF 
##  4 up    1.82e- 9 oxidoreduction-driven active transmembrane transporter… GO:MF 
##  5 up    7.94e- 9 cadherin binding                                        GO:MF 
##  6 up    2.38e- 8 primary active transmembrane transporter activity       GO:MF 
##  7 up    1.29e- 6 structural constituent of ribosome                      GO:MF 
##  8 up    1.77e- 4 NADH dehydrogenase (ubiquinone) activity                GO:MF 
##  9 up    1.77e- 4 cadherin binding involved in cell-cell adhesion         GO:MF 
## 10 up    2.15e- 4 NADH dehydrogenase (quinone) activity                   GO:MF 
## 11 up    3.14e- 4 NADH dehydrogenase activity                             GO:MF 
## 12 up    3.76e- 4 NAD(P)H dehydrogenase (quinone) activity                GO:MF 
## 13 up    4.81e- 4 proton transmembrane transporter activity               GO:MF 
## 14 up    2.43e- 3 oxidoreductase activity, acting on NAD(P)H, quinone or… GO:MF 
## 15 up    2.80e- 3 peroxiredoxin activity                                  GO:MF 
## 16 up    8.29e- 3 cell adhesion mediator activity                         GO:MF 
## 17 up    8.72e- 3 oxidoreductase activity, acting on NAD(P)H              GO:MF 
## 18 up    1.06e- 2 oxidoreductase activity                                 GO:MF 
## 19 up    1.29e- 2 cell-cell adhesion mediator activity                    GO:MF 
## 20 up    1.88e- 2 protein tag activity                                    GO:MF 
## # A tibble: 20 × 4
##    query  p_value term_name                                  source
##    <chr>    <dbl> <chr>                                      <chr> 
##  1 down  7.26e-20 protein binding                            GO:MF 
##  2 down  1.82e- 8 catalytic activity                         GO:MF 
##  3 down  8.59e- 8 heterocyclic compound binding              GO:MF 
##  4 down  3.84e- 7 nucleotide binding                         GO:MF 
##  5 down  3.85e- 7 single-stranded DNA helicase activity      GO:MF 
##  6 down  3.93e- 7 nucleoside phosphate binding               GO:MF 
##  7 down  8.40e- 7 single-stranded DNA binding                GO:MF 
##  8 down  5.34e- 6 cadherin binding                           GO:MF 
##  9 down  6.50e- 6 anion binding                              GO:MF 
## 10 down  8.80e- 6 purine nucleotide binding                  GO:MF 
## 11 down  9.91e- 6 identical protein binding                  GO:MF 
## 12 down  2.15e- 5 adenyl nucleotide binding                  GO:MF 
## 13 down  4.97e- 5 chromatin binding                          GO:MF 
## 14 down  5.54e- 5 ribonucleotide binding                     GO:MF 
## 15 down  1.03e- 4 enzyme binding                             GO:MF 
## 16 down  1.13e- 4 DNA polymerase binding                     GO:MF 
## 17 down  1.62e- 4 purine ribonucleotide binding              GO:MF 
## 18 down  1.70e- 4 purine ribonucleoside triphosphate binding GO:MF 
## 19 down  1.73e- 4 carbohydrate derivative binding            GO:MF 
## 20 down  3.22e- 4 DNA helicase activity                      GO:MF 
## # A tibble: 8 × 4
##   query  p_value term_name      source
##   <chr>    <dbl> <chr>          <chr> 
## 1 up    0.000105 hsa-let-7c-5p  MIRNA 
## 2 up    0.00335  hsa-let-7e-5p  MIRNA 
## 3 up    0.00407  hsa-miR-30a-5p MIRNA 
## 4 up    0.00411  hsa-miR-17-5p  MIRNA 
## 5 up    0.00576  hsa-miR-4460   MIRNA 
## 6 up    0.00951  hsa-miR-140-5p MIRNA 
## 7 up    0.00992  hsa-let-7a-5p  MIRNA 
## 8 up    0.0109   hsa-miR-652-3p MIRNA 
## # A tibble: 11 × 4
##    query  p_value term_name       source
##    <chr>    <dbl> <chr>           <chr> 
##  1 down  9.79e-20 hsa-miR-193b-3p MIRNA 
##  2 down  2.20e- 4 hsa-miR-744-5p  MIRNA 
##  3 down  5.95e- 4 hsa-miR-34a-5p  MIRNA 
##  4 down  1.04e- 3 hsa-miR-484     MIRNA 
##  5 down  1.10e- 3 hsa-miR-16-5p   MIRNA 
##  6 down  1.09e- 2 hsa-miR-615-3p  MIRNA 
##  7 down  1.78e- 2 hsa-miR-215-5p  MIRNA 
##  8 down  1.85e- 2 hsa-miR-1226-3p MIRNA 
##  9 down  2.61e- 2 hsa-miR-1-3p    MIRNA 
## 10 down  2.68e- 2 hsa-miR-6090    MIRNA 
## 11 down  3.06e- 2 hsa-miR-103a-3p MIRNA 
## # A tibble: 20 × 4
##    query  p_value term_name                                source
##    <chr>    <dbl> <chr>                                    <chr> 
##  1 up    1.28e-15 seminal vesicle; glandular cells[≥Low]   HPA   
##  2 up    1.28e-15 seminal vesicle                          HPA   
##  3 up    3.36e-15 endometrium 1                            HPA   
##  4 up    1.78e-14 pancreas; exocrine glandular cells[≥Low] HPA   
##  5 up    3.20e-14 pancreas                                 HPA   
##  6 up    3.74e-14 skin 2                                   HPA   
##  7 up    3.79e-14 prostate; glandular cells[≥Low]          HPA   
##  8 up    3.79e-14 prostate                                 HPA   
##  9 up    3.99e-14 endometrium 2                            HPA   
## 10 up    6.27e-14 skin 1                                   HPA   
## 11 up    1.16e-13 epididymis; glandular cells[≥Low]        HPA   
## 12 up    1.16e-13 epididymis                               HPA   
## 13 up    2.13e-13 colon                                    HPA   
## 14 up    2.37e-13 endometrium 1; glandular cells[≥Low]     HPA   
## 15 up    3.11e-13 thyroid gland; glandular cells[≥Low]     HPA   
## 16 up    3.11e-13 thyroid gland                            HPA   
## 17 up    1.33e-12 cervix; glandular cells[≥Low]            HPA   
## 18 up    1.34e-12 endometrium 2; glandular cells[≥Low]     HPA   
## 19 up    2.16e-12 gallbladder                              HPA   
## 20 up    2.16e-12 gallbladder; glandular cells[≥Low]       HPA   
## # A tibble: 20 × 4
##    query  p_value term_name                                     source
##    <chr>    <dbl> <chr>                                         <chr> 
##  1 down  1.32e-17 duodenum                                      HPA   
##  2 down  9.60e-16 skin 2; cells in spinous layer[≥Low]          HPA   
##  3 down  6.77e-15 skin 1; cells in basal layer[≥Low]            HPA   
##  4 down  7.47e-15 rectum                                        HPA   
##  5 down  1.79e-14 small intestine                               HPA   
##  6 down  3.24e-14 skin 2; cells in basal layer[≥Low]            HPA   
##  7 down  4.02e-14 skin 1; cells in spinous layer[≥Low]          HPA   
##  8 down  2.58e-13 esophagus; squamous epithelial cells[≥Low]    HPA   
##  9 down  2.58e-13 esophagus                                     HPA   
## 10 down  1.28e-12 stomach 1; glandular cells[≥Low]              HPA   
## 11 down  1.28e-12 stomach 1                                     HPA   
## 12 down  1.30e-12 skin 2; cells in spinous layer[≥Medium]       HPA   
## 13 down  1.37e-12 tonsil; germinal center cells[≥Low]           HPA   
## 14 down  1.67e-12 appendix                                      HPA   
## 15 down  2.22e-12 tonsil; squamous epithelial cells[≥Low]       HPA   
## 16 down  3.01e-12 esophagus; squamous epithelial cells[≥Medium] HPA   
## 17 down  4.55e-12 tonsil                                        HPA   
## 18 down  1.01e-11 tonsil; squamous epithelial cells[≥Medium]    HPA   
## 19 down  1.34e-11 skin 2; cells in basal layer[≥Medium]         HPA   
## 20 down  1.73e-11 lymph node; germinal center cells[≥Low]       HPA   
## # A tibble: 6 × 4
##   query  p_value term_name                                              source
##   <chr>    <dbl> <chr>                                                  <chr> 
## 1 up    8.48e-15 Cytoplasmic ribosomal proteins                         WP    
## 2 up    3.85e-14 Electron transport chain OXPHOS system in mitochondria WP    
## 3 up    9.22e- 6 Oxidative phosphorylation                              WP    
## 4 up    7.29e- 4 VEGFA VEGFR2 signaling                                 WP    
## 5 up    2.77e- 3 Nonalcoholic fatty liver disease                       WP    
## 6 up    5.00e- 2 Mitochondrial complex IV assembly                      WP    
## # A tibble: 9 × 4
##   query  p_value term_name                                  source
##   <chr>    <dbl> <chr>                                      <chr> 
## 1 down  6.31e-17 Retinoblastoma gene in cancer              WP    
## 2 down  2.49e-11 DNA replication                            WP    
## 3 down  2.90e- 5 G1 to S cell cycle control                 WP    
## 4 down  3.74e- 5 Gastric cancer network 1                   WP    
## 5 down  8.80e- 5 Cell cycle                                 WP    
## 6 down  1.18e- 3 Gastric cancer network 2                   WP    
## 7 down  1.38e- 3 DNA mismatch repair                        WP    
## 8 down  2.48e- 3 Cohesin complex Cornelia de Lange syndrome WP    
## 9 down  3.33e- 2 DNA repair pathways full network           WP    
## # A tibble: 16 × 4
##    query  p_value term_name                                         source
##    <chr>    <dbl> <chr>                                             <chr> 
##  1 up    2.97e-16 Oxidative phosphorylation                         KEGG  
##  2 up    1.06e-14 Ribosome                                          KEGG  
##  3 up    3.53e-10 Coronavirus disease - COVID-19                    KEGG  
##  4 up    1.61e- 9 Parkinson disease                                 KEGG  
##  5 up    4.37e- 9 Diabetic cardiomyopathy                           KEGG  
##  6 up    4.92e- 9 Chemical carcinogenesis - reactive oxygen species KEGG  
##  7 up    4.49e- 8 Huntington disease                                KEGG  
##  8 up    7.73e- 8 Prion disease                                     KEGG  
##  9 up    7.97e- 8 Thermogenesis                                     KEGG  
## 10 up    9.70e- 8 Pathways of neurodegeneration - multiple diseases KEGG  
## 11 up    5.49e- 7 Amyotrophic lateral sclerosis                     KEGG  
## 12 up    1.74e- 6 Alzheimer disease                                 KEGG  
## 13 up    7.76e- 5 Cardiac muscle contraction                        KEGG  
## 14 up    3.04e- 4 Non-alcoholic fatty liver disease                 KEGG  
## 15 up    1.46e- 2 Mitophagy - animal                                KEGG  
## 16 up    2.51e- 2 Lysosome                                          KEGG  
## # A tibble: 12 × 4
##    query  p_value term_name                         source
##    <chr>    <dbl> <chr>                             <chr> 
##  1 down  7.74e-11 DNA replication                   KEGG  
##  2 down  5.87e-10 Cell cycle                        KEGG  
##  3 down  5.24e- 4 Base excision repair              KEGG  
##  4 down  3.89e- 3 Oocyte meiosis                    KEGG  
##  5 down  4.87e- 3 Mismatch repair                   KEGG  
##  6 down  5.85e- 3 Fructose and mannose metabolism   KEGG  
##  7 down  7.00e- 3 Spliceosome                       KEGG  
##  8 down  8.21e- 3 Nucleotide excision repair        KEGG  
##  9 down  1.04e- 2 Biosynthesis of nucleotide sugars KEGG  
## 10 down  1.33e- 2 Metabolic pathways                KEGG  
## 11 down  2.91e- 2 Pentose phosphate pathway         KEGG  
## 12 down  3.72e- 2 Biosynthesis of amino acids       KEGG  
## # A tibble: 20 × 4
##    query      p_value term_name                                           source
##    <chr>        <dbl> <chr>                                               <chr> 
##  1 up    0.0000000135 Factor: Kaiso; motif: TCTCGCGAG                     TF    
##  2 up    0.0000000554 Factor: E2F; motif: GGCGSG                          TF    
##  3 up    0.000000565  Factor: E2F-2; motif: GCGCGCGCNCS; match class: 1   TF    
##  4 up    0.000000642  Factor: E2F-1:HES-7; motif: GGCRCGTGSYNNWNGGCGCSM;… TF    
##  5 up    0.000000703  Factor: CHD2; motif: TCTCGCGAG                      TF    
##  6 up    0.000000728  Factor: E2F4; motif: YCCCGCCNCNNSSNNSNN             TF    
##  7 up    0.000000808  Factor: ZF5; motif: GSGCGCGR                        TF    
##  8 up    0.000000903  Factor: Kaiso; motif: TCTCGCGAG; match class: 1     TF    
##  9 up    0.00000171   Factor: ZF5; motif: GGSGCGCGS; match class: 1       TF    
## 10 up    0.00000233   Factor: E2F4; motif: YCCCGCCNCNNSSNNSNN; match cla… TF    
## 11 up    0.00000433   Factor: E2F-4:DP-1; motif: TTTSGCGC                 TF    
## 12 up    0.00000491   Factor: ZF5; motif: GGSGCGCGS                       TF    
## 13 up    0.00000517   Factor: E2F; motif: GGCGSG; match class: 1          TF    
## 14 up    0.00000569   Factor: IRX-1; motif: NACRYNNNNNNNNRYGNN; match cl… TF    
## 15 up    0.00000601   Factor: p300; motif: ACNTCCG; match class: 1        TF    
## 16 up    0.00000613   Factor: Churchill; motif: CGGGNN                    TF    
## 17 up    0.00000637   Factor: c-ets-2; motif: ACCGGAWRTN                  TF    
## 18 up    0.00000657   Factor: E2F-3:HES-7; motif: NNNSGCGCSNNNNNCRCGYGNN… TF    
## 19 up    0.00000784   Factor: TCF-1; motif: ACATCGRGRCGCTGW               TF    
## 20 up    0.00000909   Factor: E2F-1; motif: NGGGCGGGARV                   TF    
## # A tibble: 20 × 4
##    query  p_value term_name                                               source
##    <chr>    <dbl> <chr>                                                   <chr> 
##  1 down  4.19e-14 Factor: E2F-4; motif: SNGGGCGGGAANN; match class: 1     TF    
##  2 down  1.55e-12 Factor: E2F-1; motif: NNNSSCGCSAANN                     TF    
##  3 down  2.19e-12 Factor: E2F-4; motif: NTTTCSCGCC; match class: 1        TF    
##  4 down  5.19e-12 Factor: E2F4; motif: YCCCGCCNCNNSSNNSNN; match class: 1 TF    
##  5 down  7.69e-12 Factor: ZF5; motif: NRNGNGCGCGCWN; match class: 1       TF    
##  6 down  1.15e-11 Factor: E2F; motif: TTTSGCGSG                           TF    
##  7 down  1.31e-11 Factor: ZF5; motif: GGSGCGCGS; match class: 1           TF    
##  8 down  3.46e-11 Factor: E2F-1; motif: NGGGCGGGARV; match class: 1       TF    
##  9 down  3.99e-11 Factor: E2F; motif: NCSCGCSAAAN                         TF    
## 10 down  4.60e-11 Factor: ZF5; motif: NRNGNGCGCGCWN                       TF    
## 11 down  1.14e-10 Factor: ZF5; motif: GSGCGCGR                            TF    
## 12 down  1.18e-10 Factor: ZF5; motif: GGSGCGCGS                           TF    
## 13 down  2.12e-10 Factor: E2F; motif: NKCGCGCSAAAN                        TF    
## 14 down  3.29e-10 Factor: E2F-2; motif: GCGCGCGCNCS                       TF    
## 15 down  3.81e-10 Factor: ZF5; motif: GSGCGCGR; match class: 1            TF    
## 16 down  7.08e-10 Factor: E2F-3:HES-7; motif: NNNSGCGCSNNNNNCRCGYGNN; ma… TF    
## 17 down  8.56e-10 Factor: ER81; motif: RCCGGAARYN; match class: 1         TF    
## 18 down  8.69e-10 Factor: E2F1; motif: GSGCGGGAAN                         TF    
## 19 down  8.71e-10 Factor: E2F-4; motif: NTTTCSCGCC                        TF    
## 20 down  1.04e- 9 Factor: E2F-1; motif: TTTSGCGCGMNR                      TF    
## # A tibble: 20 × 4
##    query  p_value term_name                                         source
##    <chr>    <dbl> <chr>                                             <chr> 
##  1 up    6.43e-11 Mitochondrial inheritance                         HP    
##  2 up    3.33e-10 Centrocecal scotoma                               HP    
##  3 up    1.21e- 9 Leber optic atrophy                               HP    
##  4 up    1.28e- 8 Central retinal vessel vascular tortuosity        HP    
##  5 up    1.28e- 8 Retinal arterial tortuosity                       HP    
##  6 up    5.67e- 8 Arterial tortuosity                               HP    
##  7 up    7.00e- 8 Mitochondrial respiratory chain defects           HP    
##  8 up    1.30e- 7 Ventricular preexcitation                         HP    
##  9 up    1.66e- 7 Normochromic anemia                               HP    
## 10 up    2.80e- 7 Vascular tortuosity                               HP    
## 11 up    2.80e- 7 Erythroid hypoplasia                              HP    
## 12 up    1.18e- 6 Abnormal radial artery morphology                 HP    
## 13 up    1.18e- 6 Elevated red cell adenosine deaminase activity    HP    
## 14 up    1.18e- 6 Radial artery aplasia                             HP    
## 15 up    1.74e- 6 Abnormal erythrocyte adenosine deaminase activity HP    
## 16 up    1.74e- 6 Retinal telangiectasia                            HP    
## 17 up    2.37e- 6 Distal peripheral sensory neuropathy              HP    
## 18 up    2.53e- 6 Macrocytic dyserythropoietic anemia               HP    
## 19 up    2.66e- 6 Malignant genitourinary tract tumor               HP    
## 20 up    3.89e- 6 Abnormal number of erythroid precursors           HP    
## # A tibble: 0 × 4
## # ℹ 4 variables: query <chr>, p_value <dbl>, term_name <chr>, source <chr>
## # A tibble: 6 × 4
##   query  p_value term_name                                                source
##   <chr>    <dbl> <chr>                                                    <chr> 
## 1 up    1.08e-10 Ribosome, cytoplasmic                                    CORUM 
## 2 up    2.90e- 5 40S ribosomal subunit, cytoplasmic                       CORUM 
## 3 up    5.99e- 5 40S ribosomal subunit, cytoplasmic                       CORUM 
## 4 up    1.95e- 4 Nop56p-associated pre-rRNA complex                       CORUM 
## 5 up    2.00e- 4 60S ribosomal subunit, cytoplasmic                       CORUM 
## 6 up    4.12e- 2 TRBP containing complex (DICER, RPL7A, EIF6, MOV10 and … CORUM 
## # A tibble: 2 × 4
##   query p_value term_name                                  source
##   <chr>   <dbl> <chr>                                      <chr> 
## 1 down  0.00630 RC complex (Replication competent complex) CORUM 
## 2 down  0.0497  Importin alpha-CAS-RanGTP complex          CORUM

Plot

unique(gprofiler_result_ordered$source) |> 
  walk(plot_dual_barplot_each_source, df = gprofiler_result_ordered)

unique(gprofiler_result_notordered$source) |> 
  walk(plot_dual_barplot_each_source, df = gprofiler_result_notordered)

TF

TF_remove_patterns <- 'Factor: |; match class: [0-9]+'
gprofiler_result_ordered_TF <- 
  gprofiler_result_ordered |> 
  filter(source == 'TF') |> 
  mutate(
    term_name = paste0(
      term_name |> 
        str_remove_all(TF_remove_patterns) |> 
        str_replace('; motif: ', ' (') |> 
        str_remove(';'),
      ')'
    )
  )

plot_dual_barplot_each_source('TF', gprofiler_result_ordered_TF)